package bitbot.md.bitstamp;

import bitbot.md.Exchange;
import bitbot.md.MarketDataType;
import bitbot.md.PairExchangeData;

public class BitstampExchange implements Exchange {
    private final ReqPolicy m_p = new ReqPolicy(1000*60, )
	@Override public String id() { return "bitstamp.net"; }
	
	@Override public void request(PairExchangeData c, int mdToReq) {
		if((mdToReq & MarketDataType.TOP.getMaskBit()) > 0  )

	}
	
	private final class ReqPolicy {
		private long m_timestamp; //first req in period timestamp
		private int m_requestsDone;
		private final long m_period;
		private final int m_requestsPerPeriod;
		
		public ReqPolicy(long period, int requestsPerPeriod) {
			m_period = period;
			m_requestsPerPeriod = requestsPerPeriod;
		}
		
		boolean allow() {
			m_requestsDone++;
			long now = System.currentTimeMillis();
			if(now - m_timestamp > m_period) {//new period started
				m_requestsDone = 1; 
				m_timestamp = now;
			} 
			return m_requestsDone < m_requestsPerPeriod; 
		}
		
	}

}
